package com.hw.dagl.service.impl;

import com.googlecode.ehcache.annotations.Cacheable;
import com.hw.dagl.model.DriverView;
import com.hw.dagl.model.Sys_Role;
import com.hw.dagl.model.Sys_User;
import com.hw.dagl.model.Vehicle;
import com.hw.dagl.service.YxxxService;
import com.hw.dao.utils.*;
import com.hw.interceptor.SystemLog;
import com.hw.utils.StringUtils;

import nl.justobjects.pushlet.util.Log;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jdbc.core.BatchPreparedStatementSetter;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import static com.hw.utils.DESCrypt.encrypt;
import static com.hw.utils.DESCrypt.toHexString;

@Service
public class YxxxServiceImpl implements YxxxService
{

  @Resource
  private OraclePageDaoBase oraclePageDaoBase;
  
  @Resource
  private OraclePageDaoBase1 oraclePageDaoBase1;

	private Logger logger= LoggerFactory.getLogger(YxxxServiceImpl.class);
  
  
  	/**
  	 * 分页查询影像审核列表
  	 */
	@Override
	@SystemLog(Modelname="影像审核",operationType="3",operationName="查询列表")
	public Page<Vehicle> findYxshxx(Page<Vehicle> pages, Vehicle info,
			String startTime, String endTime,Sys_User user) {
			StringBuffer sql =new StringBuffer(
					"select t.*,csys.dmsm1 csysmc,hp.dmsm1 hpzlmc,substr(t.fzjg,0,1)||t.hphm hphmmc,h.xm cjrxm from VEHICLE_RECORD t\n" +
					"left join (select t.* from Frm_Code t where 1=1 and t.dmlb='1007' and t.xtlb='00') hp on hp.dmz=t.hpzl\n" +  //机动车号牌种类代码
					"left join (select t.* from Frm_Code t where 1=1 and t.dmlb='1008' and t.xtlb='00') csys on csys.dmz=t.csys\n" +  //机动车车身颜色基本色调代码
					"left join SYS_USER h on t.cjr=h.yhdh where t.dazt = '1' ");
			 List<Object> args = new ArrayList<Object>();
			 if(StringUtils.isNotEmpty(info.getXh())){
			        sql.append(" AND t.xh = ? ");
			        args.add(info.getXh());
			    }
			 //SimpleDateFormat formatDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");	//where t.yxzt=0 
			 if(StringUtils.isNotEmpty(startTime)) {
					sql.append(" and t.cjsj >= to_date(?,'yyyy-MM-dd hh24:mi:ss') ");
					args.add(startTime);
				}
				if(StringUtils.isNotEmpty(endTime)) {
					sql.append(" AND t.cjsj <= to_date(?,'yyyy-mm-dd hh24:mi:ss') ");
					args.add(endTime);
				}
			    if(StringUtils.isNotEmpty(info.getHphm())){
			        sql.append(" AND t.hphm = ? ");
			        args.add(info.getHphm());
			    }
			    if(StringUtils.isNotEmpty(info.getHpzl())){
			        sql.append(" AND t.hpzl = ? ");
			        args.add(info.getHpzl());
			    }
			    sql.append(" order by t.cjsj desc ");
			return oraclePageDaoBase.queryForPage(sql.toString(), pages,new RowMapper<Vehicle>() {
				private EntityTools<Vehicle> et = new EntityTools<Vehicle>();
				@Override
				public Vehicle mapRow(ResultSet arg0, int arg1) throws SQLException {
					Vehicle veh = new Vehicle();
					et.setColumnsValueByResultSet(arg0, veh);
					return veh;
				}
			}, args.toArray());
		
	}


	@Override
	@SystemLog(Modelname="影像审核详情",operationType="3",operationName="查询详情")
	public Vehicle findYxshByxhFirstIn(Vehicle info, String startTime, String endTime) {
		
	 StringBuffer sql=new StringBuffer("select t.*,csys.dmsm1 csysmc,hp.dmsm1 hpzlmc,substr(t.fzjg,0,1)||t.hphm hphmmc from\n"+
				"(select t.*,r.tpurl from VEHICLE_RECORD t,VEHICLE_PIC3 r where t.xh=r.xh and t.dazt = '1' ");
	    if (StringUtils.isNotEmpty(startTime)) {
	      sql.append(" AND t.cjsj >= to_date('" + startTime + "','yyyy-MM-dd hh24:mi:ss')");
	    }

	    if (StringUtils.isNotEmpty(info.getHpzl())) {
	    	sql.append(" AND t.hpzl =  '" + info.getHpzl() + "'");
        }
	    
	    if (StringUtils.isNotEmpty(endTime)) {
	    	sql.append(" AND t.cjsj <= to_date('" + endTime + "','yyyy-MM-dd hh24:mi:ss')");
	    }
	 
	    String xh=info.getXh();
	    if (StringUtils.isNotEmpty(xh)) {
	    	sql.append(" AND t.xh =  '" + xh+ "'");
	    }	
	    sql.append(
		" )  t "
		+ "left join (select t.* from Frm_Code t where 1=1 and t.dmlb='1007' and t.xtlb='00') hp on hp.dmz=t.hpzl\n" + 
		"left join (select t.* from Frm_Code t where 1=1 and t.dmlb='1008' and t.xtlb='00') csys on csys.dmz=t.csys ");

	    //queryForObject在查询不到数据的时候会报空指针异常
	    List<Vehicle> vehicles=oraclePageDaoBase.query(sql.toString(),new BeanPropertyRowMapper<Vehicle>(Vehicle.class));
		if(vehicles.size()>0){
			 info=vehicles.get(0);
		}else{
			info=new Vehicle();
		}
		 return info;
	}

	@Override
	@SystemLog(Modelname="档案删除",operationType="4",operationName="删除档案记录")
	@Transactional(readOnly=false,rollbackFor=Exception.class)
	public int delVehcile(String xh,String lsh,String bussinessType) {

		String sql =" DELETE FROM VEHICLE_RECORD t WHERE t.xh=? and t.lsh=?";
		String sql1 =" DELETE FROM VEHICLE_pic t WHERE t.xh=? and lsh=?";
		if("2".equals(bussinessType)){
			sql =" DELETE FROM driver_audit t WHERE t.xh=?";
		}
		logger.info("删除档案信息主表sql "+sql);
		logger.info("删除档案信息副表sql "+sql1);
		int num = oraclePageDaoBase.update(sql,xh,lsh);
		int num1 = oraclePageDaoBase.update(sql1,xh,lsh);
		return num;
	}

	@Override
	public GcPage<Vehicle> findYxshByxhUpAndDown(GcPage<Vehicle> pages,
			Vehicle info, String startTime, String endTime) {
		String sql="select t.*,r.tpurl from VEHICLE_RECORD t,Vehicle_Pic3 r where t.xh=r.xh and t.dazt='1'";
		List<Object> args = new ArrayList<Object>();
			if (StringUtils.isNotEmpty(info.getHphm())) {
			    sql = sql + " and t.hphm = '" + info.getHphm() + "'";
			}

		    if (StringUtils.isNotEmpty(info.getHpzl())) {
		      sql = sql + " AND t.hpzl =  '" + info.getHpzl() + "'";
		    }
		    if (StringUtils.isNotEmpty(startTime)) {
		      sql = sql + " AND t.cjsj >= to_date('" + startTime + "','yyyy-MM-dd hh24:mi:ss')";
		    }

		    if (StringUtils.isNotEmpty(endTime)) {
		      sql = sql + " AND t.cjsj <= to_date('" + endTime + "','yyyy-MM-dd hh24:mi:ss')";
		    }	    
		   sql+=" order by cjsj desc ";		    	    
		return oraclePageDaoBase.queryForGcPage(sql.toString(), pages, new RowMapper<Vehicle>() {
			private EntityTools<Vehicle> et = new EntityTools<Vehicle>();
			@Override
			public Vehicle mapRow(ResultSet arg0, int arg1)
					throws SQLException {
				Vehicle veh = new Vehicle();
				et.setColumnsValueByResultSet(arg0, veh);
				return veh;
			}
		}, new Object[]{});
	}

	@Override
	public List<Vehicle> findYxshByxh(Vehicle info) {
		String sql ="select * from VEHICLE t,VEHICLE_PIC r where t.xh=r.xh and t.xh='"+ info.getXh()+ "'";
		return oraclePageDaoBase.query(sql, new RowMapper<Vehicle>(){
			private EntityTools<Vehicle> et = new EntityTools<Vehicle>();
			@Override
			public Vehicle mapRow(ResultSet arg0, int arg1) throws SQLException {
				Vehicle veh = new Vehicle();
				et.setColumnsValueByResultSet(arg0, veh);
				return veh;
			}});
	}
	
	
	
	/**
  	 * 分页查询影像采集列表
  	 */
	@Override
	@SystemLog(Modelname="影像采集",operationType="3",operationName="查询列表")
	public Page<Vehicle> findYxcjxx(Page<Vehicle> pages, Vehicle info,
			String startTime, String endTime) {
		List<Object> argsveh = new ArrayList<Object>();
		StringBuffer sqlveh= new StringBuffer("");
		 String hphm=info.getHphm();
	        if(StringUtils.isNotEmpty(hphm)){
	        	sqlveh.append(" select distinct xh from vehicle_record where 1=1 and hphm = ? ");
	        	argsveh.add(hphm);
	        }
	        if(StringUtils.isNotEmpty(info.getHpzl())){
	        	sqlveh.append(" AND hpzl = ? ");
	        	argsveh.add(info.getHpzl());
	        }
	        List<Vehicle> list = null;
	        if(StringUtils.isNotEmpty(hphm)){
	        
				list =  oraclePageDaoBase.query(sqlveh.toString(), argsveh.toArray(),new RowMapper<Vehicle>() {
					private EntityTools<Vehicle> et = new EntityTools<Vehicle>();
					@Override
					public Vehicle mapRow(ResultSet arg0, int arg1) throws SQLException {
						Vehicle veh = new Vehicle();
						et.setColumnsValueByResultSet(arg0, veh);
						return veh;
					}
				});
	        if(list==null || list.size()<1) return new Page<Vehicle>();
	     }
	      
		StringBuffer sql =new StringBuffer("select t.*,'皖'||t.hphm hphmmc,case when t.sjly='0' then h.xm else t.cjr end  cjrxm,hp.dmsm1 hpzlmc,"
		        + "(SELECT applyNo from dagl_T_Audit where 1=1 and applicant=? and trim(lsh)=t.lsh and trim(xh)=t.xh and zt='1' AND permissiontype='03' and flag='1') AS scqx"
		        + " from VEHICLE_RECORD t\n" +
						"left join (select t.* from Frm_Code t where 1=1 and t.dmlb='1007' and t.xtlb='00') hp on hp.dmz=t.hpzl\n" + 
						//"left join VEH_OPERTYPE r on t.ywlx=r.ywlx and t.ywyy=r.ywyy \n" + 
						"left join SYS_USER h on t.cjr=h.yhdh where 1=1 ");
		    List<Object> args = new ArrayList<Object>();
		    String cjr=info.getCjr();//此处创建人就是当前登录人
		    args.add(cjr);
		   
			if(StringUtils.isNotEmpty(hphm)){
			String xhStrs="";
			if(list.size()>0){
	        	for(int i=0; i<list.size();i++){
	        		if(i==0) xhStrs+="'"+list.get(i).getXh()+"'";
	        		else xhStrs+=",'"+list.get(i).getXh()+"'";
	        	}
	          sql.append(" AND t.xh in ("+xhStrs+") ");
	         // args.add(xhStrs);	        	
	        } 
			}
	        if(StringUtils.isNotEmpty(info.getHpzl())){
	        	sql.append(" AND t.hpzl = ? ");
	        	args.add(info.getHpzl());
	        }
	        String dabh=info.getDabh();
	        if(StringUtils.isNotEmpty(dabh)){
				sql.append(" AND t.dabh = ? ");
				args.add(dabh);
			}
	        if(StringUtils.isNotEmpty(info.getLsh())) {
				sql.append(" and t.lsh =? ");
				args.add(info.getLsh());
			}
	        
	        sql.append(" order by t.cjsj desc ");
	        
	        logger.info(sql.toString());
	    Page<Vehicle> pages2=oraclePageDaoBase.queryForPage(sql.toString(), pages,new RowMapper<Vehicle>() {
			private EntityTools<Vehicle> et = new EntityTools<Vehicle>();
			@Override
			public Vehicle mapRow(ResultSet arg0, int arg1) throws SQLException {
				Vehicle veh = new Vehicle();
				char[] ch;
				et.setColumnsValueByResultSet(arg0, veh);
				if(veh.getYwlx()!=null && veh.getYwyy().length()>=1){
			         StringBuffer buf=new StringBuffer();
		    		 List<Vehicle> operList=queryOpertype(veh.getYwlx());
		    		 ch=veh.getYwyy().toCharArray();
		    		 for(int i = 0;i<ch.length;i++){
		    			 for(Vehicle v : operList){
		    				 if(v.getYwyy().equals(String.valueOf(ch[i]))){
		    					 if(i==0){
		    						 buf.append(v.getYwmc());
		    					 }else{
		    						 buf.append("|"+v.getYwmc());
		    					 }
		    				 }
		    			 }
		    			}
		    		 veh.setYwmc(buf.toString());
		    	}
				return veh;
			}
		}, args.toArray());
		return pages2;
		
		
		/*
		StringBuffer sql =new StringBuffer(
						"select t.*,hp.dmsm1 hpzlmc,'皖'||t.hphm hphmmc,case when t.sjly='0' then h.xm else t.cjr end  cjrxm,r.ywmc from VEHICLE_RECORD t\n" +
						"left join (select t.* from Frm_Code t where 1=1 and t.dmlb='1007' and t.xtlb='00') hp on hp.dmz=t.hpzl\n" + 
						"left join VEH_OPERTYPE r on t.ywlx=r.ywlx and t.ywyy=r.ywyy\n" + 
						"left join SYS_USER h on t.cjr=h.yhdh where 1=1 ");
		 List<Object> args = new ArrayList<Object>();
		 if(StringUtils.isNotEmpty(startTime)) {
				sql.append(" and t.cjsj >= to_date(?,'yyyy-MM-dd hh24:mi:ss') ");
				args.add(startTime);
			}
			if(StringUtils.isNotEmpty(endTime)) {
				sql.append(" AND t.cjsj <= to_date(?,'yyyy-mm-dd hh24:mi:ss') ");
				args.add(endTime);
			}
	        if(StringUtils.isNotEmpty(info.getHphm())){
	            sql.append(" AND t.hphm = ? ");
	            args.add(info.getHphm());
	        }
	        if(StringUtils.isNotEmpty(info.getHpzl())){
	            sql.append(" AND t.hpzl = ? ");
	            args.add(info.getHpzl());
	        }
	        if(StringUtils.isNotEmpty(info.getLsh())){
	            sql.append(" AND t.lsh = ? ");
	            args.add(info.getLsh());
	        }
	        sql.append(" order by t.cjsj desc ");
	     
	        final StringBuffer buf=new StringBuffer();
	    	//final char[] ch;
	        
		return oraclePageDaoBase.queryForPage(sql.toString(), pages,new RowMapper<Vehicle>() {
			private EntityTools<Vehicle> et = new EntityTools<Vehicle>();
			@Override
			public Vehicle mapRow(ResultSet arg0, int arg1) throws SQLException {
				Vehicle veh = new Vehicle();
				char[] ch;
				et.setColumnsValueByResultSet(arg0, veh);
				if(veh.getYwyy().length()>1){
		    		 List<Vehicle> operList=queryOpertype(veh.getYwlx());
		    		 ch=veh.getYwyy().toCharArray();
		    		 for(int i = 0;i<ch.length;i++){
		    			 for(Vehicle v : operList){
		    				 if(v.getYwyy().equals(String.valueOf(ch[i]))){
		    					 if(i==0){
		    						 buf.append(v.getYwmc());
		    					 }else{
		    						 buf.append("|"+v.getYwmc());
		    					 }
		    				 }
		    			 }
		    			}
		    		 veh.setYwmc(buf.toString());
		    	}
				return veh;
			}
		}, args.toArray());*/
	}

	@Override
	@SystemLog(Modelname="机动车档案补录",operationType="3",operationName="查询补录详情")
	public Vehicle findYxcjByxhFirstIn(
			Vehicle info, String startTime, String endTime) {
		String sql="select t.*,hp.dmsm1 hpzlmc,'皖'||t.hphm hphmmc,h.xm cjrxm from VEHICLE_RECORD t\n" +
				"left join (select t.* from Frm_Code t where 1=1 and t.dmlb='1007' and t.xtlb='00') hp on hp.dmz=t.hpzl\n" + 
				//"left join VEH_OPERTYPE r on t.ywlx=r.ywlx and t.ywyy=r.ywyy\n" + 
				"left join SYS_USER h on t.cjr=h.yhdh where 1=1 ";
		List<Object> args = new ArrayList<Object>();
			if (StringUtils.isNotEmpty(info.getHphm())) {
			    sql = sql + " and t.hphm = '" + info.getHphm() + "'";
			}
		    if (StringUtils.isNotEmpty(info.getHpzl())) {
		      sql = sql + " AND t.hpzl =  '" + info.getHpzl() + "'";
		    }
		    if (StringUtils.isNotEmpty(startTime)) {
		      sql = sql + " AND t.cjsj >= to_date('" + startTime + "','yyyy-MM-dd hh24:mi:ss')";
		    }

		    if (StringUtils.isNotEmpty(endTime)) {
		      sql = sql + " AND t.cjsj <= to_date('" + endTime + "','yyyy-MM-dd hh24:mi:ss')";
		    }
		    if(StringUtils.isNotEmpty(info.getLsh())){
	            sql =sql +" AND t.lsh = '"+info.getLsh()+"'";
	        }	    
		    if(StringUtils.isNotEmpty(info.getXh())){
	            sql =sql +" AND t.xh = '"+info.getXh()+"'";
	        }	
		List<Vehicle> list= oraclePageDaoBase.query(sql.toString(), new RowMapper<Vehicle>() {
			private EntityTools<Vehicle> et = new EntityTools<Vehicle>();
			@Override
			public Vehicle mapRow(ResultSet arg0, int arg1)
					throws SQLException {
				Vehicle veh = new Vehicle();
				et.setColumnsValueByResultSet(arg0, veh);
				return veh;
			}
		});
		if(list.size()>0){
			info=list.get(0);
		    	StringBuffer buf=new StringBuffer();
		    	char[] ch;
		    	if(info.getYwyy()!=null && info.getYwyy().length()>=1){
		    		 List<Vehicle> operList=queryOpertype(info.getYwlx());
		    		 ch=info.getYwyy().toCharArray();
		    		 //str =new String[veh.getYwyy().length()];
		    		 for(int i = 0;i<ch.length;i++){
		    			 for(Vehicle v : operList){
		    				 if(v.getYwyy().equals(String.valueOf(ch[i]))){
		    					 if(i==0){
		    						 buf.append(v.getYwmc());
		    					 }else{
		    						 buf.append("|"+v.getYwmc());	 
		    					 }
		    				 }
		    			 }
		    			}
		    		 info.setYwmc(buf.toString());
		    	}
		}else{
			info=new Vehicle();
		}
		 return info;
	}

	/*@Override
	public GcPage<Vehicle> findYxcjByxhUpAndDown(GcPage<Vehicle> pages,
			Vehicle info, String startTime, String endTime) {
		String sql="select t.*,d.dmsm1 hpzlmc,f.dmsm1 csysmc,substr(t.fzjg,0,1)||t.hphm hphmmc from VEHICLE_RECORD t,\n" +
				"(select r.dmz,r.dmsm1 from FRM_CODE r where xtlb=00 and dmlb=1007) d,\n" + //号牌种类
				"(select r.dmz,r.dmsm1 from FRM_CODE r where xtlb=00 and dmlb=1008) f\n" +  //车身颜色
				"where t.hpzl=d.dmz and t.csys=f.dmz ";
		List<Object> args = new ArrayList<Object>();
			if (StringUtils.isNotEmpty(info.getHphm())) {
			    sql = sql + " and t.hphm = '" + info.getHphm() + "'";
			}
			String hphm="";
			try {
				hphm = URLDecoder.decode(info.getHphm(), "UTF-8");
				info.setHphm(hphm);
			} catch (UnsupportedEncodingException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}			
		      sql = sql + " AND t.hphm = '" + info.getHphm() + "'";
		    }

		    if (StringUtils.isNotEmpty(info.getHpzl())) {
		      sql = sql + " AND t.hpzl =  '" + info.getHpzl() + "'";
		    }
		    if (StringUtils.isNotEmpty(startTime)) {
		      sql = sql + " AND t.cjsj >= to_date('" + startTime + "','yyyy-MM-dd hh24:mi:ss')";
		    }

		    if (StringUtils.isNotEmpty(endTime)) {
		      sql = sql + " AND t.cjsj <= to_date('" + endTime + "','yyyy-MM-dd hh24:mi:ss')";
		    }
		    if(StringUtils.isNotEmpty(info.getDazt()) && !info.getDazt().equals("4")){ //全部
	            sql =sql +" AND t.dazt ='"+info.getDazt()+"'";
	        }	
		    sql +=" order by t.cjsj desc ";
		return oraclePageDaoBase.queryForGcPage(sql.toString(), pages, new RowMapper<Vehicle>() {
			private EntityTools<Vehicle> et = new EntityTools<Vehicle>();
			@Override
			public Vehicle mapRow(ResultSet arg0, int arg1)
					throws SQLException {
				Vehicle veh = new Vehicle();
				et.setColumnsValueByResultSet(arg0, veh);
				return veh;
			}
		}, new Object[]{});
	}*/

	@Override
	public List<Vehicle> findYxcjByxh(Vehicle info) {
		String sql ="select * from VEHICLE_PIC r where r.lsh='"+ info.getLsh()+ "' and r.xh='"+ info.getXh()+ "'";
		List<Vehicle> listVehicle= oraclePageDaoBase.query(sql, new RowMapper<Vehicle>(){
			private EntityTools<Vehicle> et = new EntityTools<Vehicle>();
			@Override
			public Vehicle mapRow(ResultSet arg0, int arg1) throws SQLException {
				Vehicle veh = new Vehicle();
				et.setColumnsValueByResultSet(arg0, veh);
				return veh;
			}});
		 Document doc=null;
		try {
			doc = DocumentHelper.parseText(listVehicle.get(0).getTpurl());
		} catch (DocumentException e1) {
			e1.printStackTrace();
		}
		 Element root = doc.getRootElement();
		 List nodes = root.elements();
		 List<Vehicle> list = new ArrayList<Vehicle>();
		 for (Iterator<?> it = nodes.iterator(); it.hasNext();) {
			 Vehicle obj =new Vehicle();
		 Element e = (Element) it.next();
		 obj.setId(e.attributeValue("id"));
		 obj.setSingleIpaddress(e.getStringValue());
		 try {
				obj.setSingleIpaddressEncrypt(toHexString(encrypt(e.getStringValue(), "ahhwxxjs")).toUpperCase());
			} catch (Exception e1) {
				e1.printStackTrace();
			}
		 list.add(obj);
		 }
	return list;
	}

	@Override
	@SystemLog(Modelname="影像审核详情",operationType="2",operationName="修改详情")
	@Transactional(readOnly=false,rollbackFor=Exception.class)
	public boolean updateYxshzt(Vehicle info) {
		String sql="update VEHICLE_RECORD set dazt=? where xh=? ";
		String sqlInsert = "insert into VEHICLE_AUDIT\n" +
						   "select r.xh,r.hphm,r.hpzl,r.clpp1,r.clsbdh,r.fdjh,r.csys,r.syr,r.fzjg,r.glbm,r.xzqh,r.gxsj,r.cjr,r.cjsj,r.gxsj\n" + 
						   " from VEHICLE_RECORD r where r.xh=?";

		List<Object> args = new ArrayList<Object>(); 
		if (StringUtils.isNotEmpty(info.getDazt())&&StringUtils.isNotEmpty(info.getXh())) {
			args.add(info.getDazt());
			args.add(info.getXh());
		 }else{
			 return false;
		 }
		//审核通过与否都要更新VEHICLE_RECORD表状态，然后根据审核状态确定是否插入VEHICLE_AUDIT(审核通过表)
		 int UpdateNum= oraclePageDaoBase.update(sql, args.toArray());
		//状态2为审核通过，则插入，否则不操作
		if(info.getDazt().equals("2")){
		 int insertNum=oraclePageDaoBase.update(sqlInsert, new Object[]{info.getXh()});
		 return UpdateNum>0 && insertNum>0 ? true : false;
		}
		return UpdateNum>0 ? true : false;
	}

	@Override
	@Transactional(readOnly=false,rollbackFor=Exception.class)
	@SystemLog(Modelname="影像采集详情",operationType="2",operationName="修改详情")
	public boolean updateYxcjByxh(final String xh,final String[] tpurlarray) {
		boolean flag=false;
		String delSql="delete from VEHICLE_PIC t where t.xh=?";
		String inSql="insert into VEHICLE_PIC (tpurl,xh,tpid) values (?,?,DJGL_S_GCBH.NEXTVAL)";
		String updateSql="update VEHICLE set yxzt='1' where xh=? ";
		int delnum=oraclePageDaoBase.update(delSql, xh);
		if (delnum>=1){
			int[] num= oraclePageDaoBase.batchUpdate(inSql, new BatchPreparedStatementSetter() {
				
				@Override
				public void setValues(PreparedStatement ps, int i) throws SQLException {
					ps.setString(1, tpurlarray[i]);
					ps.setString(2, xh);
				}
				
				@Override
				public int getBatchSize() {
					return tpurlarray.length;
				}
			});
			int updatenum=oraclePageDaoBase.update(updateSql, xh);
			if(num.length>=1&&updatenum>=1) flag=true;
		}
		return flag;
	}

    @Override
    public Vehicle queryByHphm(String hphm) {
       String sql=" select * from vehicle where hphm='"+hphm+"' ";
       List<Vehicle> list=oraclePageDaoBase.query(sql, new BeanPropertyRowMapper<Vehicle>(Vehicle.class));
       int size=list.size();
       if(size==0){
           return new Vehicle();
       }else{
           return list.get(0);
       }
    }

    @Override
    public DriverView queryBySfz(String sfz) {
        String sql=" select xm,decode(xb,0,'女',1,'男') as xb,sfzmhm,fzjg from driver_record where sfzmhm='"+sfz+"' ";
        List<DriverView> list=oraclePageDaoBase.query(sql, new BeanPropertyRowMapper<DriverView>(DriverView.class));
        int size=list.size();
        if(size==0){
            return new DriverView();
        }else{
            return list.get(0);
        }
    }

	@Override
	public List<Vehicle> queryVehcileLsList(Vehicle info,Sys_Role sysRole) {
		String sqlvehicle="";
		StringBuffer sql=new StringBuffer(
				"select v.dabh,t.lsh,t.xh,t.ywlx,t.ywyy,r.ywmc,t.syr,t.hpzl,t.hphm,t.clpp1,t.xzqh,t.glbm,t.clsbdh,d.dmsm1 hpzlmc,'皖'||t.hphm hphmmc,"
				+ "to_char(t.bjrq,'yyyy-mm-dd hh24:mi:ss') bjrq\n" +
				" from VEH_FLOW t,VEH_OPERTYPE r,(select r.dmz,r.dmsm1 from FRM_CODE r where xtlb='00' and dmlb='1007') d, vehicle v\n" +  //号牌种类
				" where t.hpzl=d.dmz  and t.ywlx=r.ywlx(+) and t.ywyy=r.ywyy(+) and t.xh=v.xh(+) and t.ywlx not in ('P','R') ");
		 List<Vehicle> list = null;
		 List<Vehicle> listvehicle = null;
		 List<Object> args = new ArrayList<Object>();
		 List<Object> argsvehicle = new ArrayList<Object>();
		if(StringUtils.isNotEmpty(info.getLsh())){
			sql.append(" AND t.lsh = ? ");
			args.add(info.getLsh());
			if(StringUtils.isNotEmpty(info.getHphm())) {
				sql.append(" AND t.hphm = ? ");
				args.add(info.getHphm());
			}
		   if(StringUtils.isNotEmpty(info.getHpzl())) {
				sql.append(" and t.hpzl = ?");
				args.add(info.getHpzl());
			}
		}else if(StringUtils.isNotEmpty(info.getLsh()) && StringUtils.isNotEmpty(info.getHphm())){
	    	
			sql.append(" AND t.lsh = ? ");
			args.add(info.getLsh());
			sql.append(" AND t.hphm = ? ");
			args.add(info.getHphm());
		   if(StringUtils.isNotEmpty(info.getHpzl())) {
				sql.append(" and t.hpzl = ?");
				args.add(info.getHpzl());
			}
		   sql.append("  order by t.bjrq desc ");
		   		   
	    }else if(StringUtils.isNotEmpty(info.getHphm()) && StringUtils.isNotEmpty(info.getHpzl())){
	    	sqlvehicle="select distinct xh from veh_flow t where t.hphm=? and t.hpzl=? ";
	    	argsvehicle.add(info.getHphm());
	    	argsvehicle.add(info.getHpzl());
	    	logger.info(sqlvehicle.toString());
	    	listvehicle=oraclePageDaoBase.query(sqlvehicle.toString(),argsvehicle.toArray(), new BeanPropertyRowMapper<Vehicle>(Vehicle.class));
	    	String str="";
	    	if(listvehicle.size()>0){
	    		for(int i=0;i<listvehicle.size();i++){
	    			if(i==0) str+= "'"+listvehicle.get(i).getXh()+"'";
	    			else str+=",'"+listvehicle.get(i).getXh()+"'";
	    		}
	    		sql.append(" AND t.xh in ("+str+") ");
				//args.add(str);
				logger.info(str);
				sql.append("  order by t.bjrq desc ");
	    	}else{
	    		return null;
	    	}
	    }
				 
		   logger.info(sql.toString());
		   list=oraclePageDaoBase.query(sql.toString(),args.toArray(), new BeanPropertyRowMapper<Vehicle>(Vehicle.class)); 	         
	    
	    for(Vehicle veh : list){
	    	StringBuffer buf=new StringBuffer();
	    	char[] ch;
	    	if(veh.getYwyy()!=null && veh.getYwyy().length()>=1){
	    		 List<Vehicle> operList=queryOpertype(veh.getYwlx());
	    		 ch=veh.getYwyy().toCharArray();
	    		 for(int i = 0;i<ch.length;i++){
	    			 for(Vehicle v : operList){
	    				 if(v.getYwyy().equals(String.valueOf(ch[i]))){
	    					 if(i==0){
	    						 buf.append(v.getYwmc());
	    					 }else{
	    						 buf.append("|"+v.getYwmc());
	    					 }
	    				 }
	    			 }
	    			}
	    		 veh.setYwmc(buf.toString());
	    	}
	    }
		return  list;

	}
	@Override
	public List<Vehicle> queryOpertype(String ywlx) {
		String sqlOpertype ="select t.ywlx,ywyy,ywmc from VEH_OPERTYPE t where  ywlx=?";
	    List<Vehicle> listOper=oraclePageDaoBase.query(sqlOpertype.toString(),new Object[]{ywlx}, new BeanPropertyRowMapper<Vehicle>(Vehicle.class));
		return listOper;
	}
	
	@Override
	public boolean queryVehcileIsNot(String lsh,String xh) {
		StringBuffer sql=new StringBuffer("select * from VEHICLE_RECORD t where  lsh='"+lsh+"'and xh='"+xh+"'");
		List<Vehicle> list=oraclePageDaoBase.query(sql.toString(), new BeanPropertyRowMapper<Vehicle>(Vehicle.class));
		return list.size()>0 ? true : false;
	}
	
	@Override
	public List<Vehicle> queryVehicleList(Vehicle info, String startTime, String endTime, PageUtil page) {
		    long currentPage=page.getCurrentPage();//当前页数
	        long pageSize=page.getPageSize();//每页大小
	        long max=(currentPage+1)*pageSize;
	        long min=(currentPage-1)*pageSize;
	        StringBuilder sql=new StringBuilder("select * from (");
	        sql.append(" select ROWNUM rn,lsh FROM ( ");
	        sql.append(" select lsh FROM VEHICLE_RECORD t where 1=1 ");
	        if (StringUtils.isNotEmpty(startTime)) {
	            sql .append(" AND t.cjsj >= to_date('"+ startTime+"','yyyy-MM-dd hh24:mi:ss')");
	        }

	        if (StringUtils.isNotEmpty(endTime)) {
	           sql .append(" AND t.cjsj <= to_date('" + endTime + "','yyyy-MM-dd hh24:mi:ss')");
	        }
	       
	        String hpzl=info.getHpzl();
	        if (StringUtils.isNotEmpty(hpzl)) {
	           sql .append(" AND t.hpzl='"+ hpzl+ "'");
	        }
	        String hphm=info.getHphm();
	        if (StringUtils.isNotEmpty(hphm)) {
	           sql .append(" AND t.hphm='"+ hphm+ "'");
	        }
	        sql.append(" ORDER BY T.CJSJ DESC ");
	        sql.append(" ) where rownum<'"+max+"' ");
	        sql.append(") where rn>'"+min+"' ");
	        List<Vehicle> vehicles= oraclePageDaoBase.query(sql.toString(), new BeanPropertyRowMapper<Vehicle>(Vehicle.class));
	        return vehicles;
	}

	/*@Override
	public DriverView queryDriverBysfzmhm(DriverView info) {
		String sql="select t.dabh,t.sfzmhm,t.fzjg,t.xm,t.xb from DRIVINGLICENSE t where sfzmhm='"+info.getSfzmhm()+"'";
	    List<DriverView> list=oraclePageDaoBase.query(sql, new BeanPropertyRowMapper<DriverView>(DriverView.class));
		
		if(list.size()>0){
		  String sql2="select * from DRIVER_RECORD t where sfzmhm='"+info.getSfzmhm()+"'";
		  List<DriverView> list2=oraclePageDaoBase.query(sql2, new BeanPropertyRowMapper<DriverView>(DriverView.class));
		  if(list2.size()>0){
			  list2.get(0).setZzz("1");
			  return list2.get(0);
		  }else{
			  return list.get(0);
		  }
		}
		  return  null;
	   }*/
/*	@Override
	public DriverView queryDriverOBjBysfzmhm(DriverView info) {
		String sql="select t.xh,t.dabh,t.sfzmhm,t.fzjg,t.xm,t.xb,decode(t.xb,'1','男','0','女','男') xbmc from DRIVINGLICENSE t where sfzmhm='"+info.getSfzmhm()+"'";
	    List<DriverView> list=oraclePageDaoBase.query(sql, new BeanPropertyRowMapper<DriverView>(DriverView.class));
		  return  list.size()>0 ? list.get(0) : null;
	   }*/
	@Override
	public DriverView queryDriverByxh(DriverView info) {
		String sql="select t.dabh,t.xh,t.sfzmmc,t.sfzmhm,t.xm,decode(t.xb,'1','男','0','女','男') xbmc,t.xb,t.fzjg,t.gxsj from DRIVINGLICENSE t where sfzmhm='"+info.getXh()+"'";
		List<DriverView> list =oraclePageDaoBase.query(sql, new BeanPropertyRowMapper<DriverView>(DriverView.class));
		return list.size()>0 ? list.get(0) : null;
	}

	@Override
	public Page<DriverView> findDriverYxcjxx(Page<DriverView> pages, DriverView info, String startTime,String endTime) {
				StringBuffer sql =new StringBuffer(
						"select t.*,decode(t.xb,'1','男','0','女','男') xbmc,h.xm cjrxm from DRIVER_RECORD t \n" +
						"left join SYS_USER h on t.cjr=h.yhdh where 1=1 ");
		 List<Object> args = new ArrayList<Object>();
		   if(StringUtils.isNotEmpty(info.getSfzmhm())) {
				sql.append(" AND t.sfzmhm = ? ");
				args.add(info.getSfzmhm());
			}
		   if(StringUtils.isNotEmpty(info.getDabh())) {
				sql.append(" AND t.dabh = ? ");
				args.add(info.getDabh());
			}
		   if(StringUtils.isNotEmpty(startTime)) {
				sql.append(" and t.cjsj >= to_date(?,'yyyy-MM-dd hh24:mi:ss') ");
				args.add(startTime);
			}
			if(StringUtils.isNotEmpty(endTime)) {
				sql.append(" AND t.cjsj <= to_date(?,'yyyy-mm-dd hh24:mi:ss') ");
				args.add(endTime);
			}
		    if(info.getDazt().equals("4")){ //全部
		        sql.append(" AND t.dazt in ('1','3') ");
		    }else{
		    	sql.append(" AND t.dazt =? ");
		        args.add(info.getDazt());
		    }
		    sql.append(" order by t.cjsj desc ");
		return oraclePageDaoBase.queryForPage(sql.toString(), pages,new RowMapper<DriverView>() {
			private EntityTools<DriverView> et = new EntityTools<DriverView>();
			@Override
			public DriverView mapRow(ResultSet arg0, int arg1) throws SQLException {
				DriverView driver = new DriverView();
				et.setColumnsValueByResultSet(arg0, driver);
				return driver;
			}
		}, args.toArray());
	}

	/*@Override
	public GcPage<DriverView> findDriverYxcjFirstIn(GcPage<DriverView> pages, DriverView info, String startTime,
			String endTime) {
		String sql="select t.*,decode(t.xb,'1','男','0','女','男') xbmc from DRIVER_RECORD t \n" +
						" where 1=1 ";
		String sql2="select * from (select v.*,rownum rowNumber  "
				+ "from (select t.*,decode(t.xb,'1','男','0','女','男') xbmc from DRIVER_RECORD t \n" +
						" where 1=1 ";
		List<Object> args = new ArrayList<Object>();
		
			if (StringUtils.isNotEmpty(info.getSfzmhm())) {
			    sql = sql + " and t.sfzmhm = '" + info.getSfzmhm() + "'";
			    sql2 = sql2 + " and t.sfzmhm = '" + info.getSfzmhm() + "'";
			}
		    if (StringUtils.isNotEmpty(startTime)) {
		      sql = sql + " AND t.cjsj >= to_date('" + startTime + "','yyyy-MM-dd hh24:mi:ss')";
		      sql2 = sql2 + " AND t.cjsj >= to_date('" + startTime + "','yyyy-MM-dd hh24:mi:ss')";
		    }

		    if (StringUtils.isNotEmpty(endTime)) {
		      sql = sql + " AND t.cjsj <= to_date('" + endTime + "','yyyy-MM-dd hh24:mi:ss')";
		      sql2 = sql2 + " AND t.cjsj <= to_date('" + endTime + "','yyyy-MM-dd hh24:mi:ss')";
		    }
		    if(StringUtils.isNotEmpty(info.getDazt()) && !info.getDazt().equals("4")){ //全部
	            sql =sql +" AND t.dazt = '"+info.getDazt()+"'";
	            sql2 =sql2 +" AND t.dazt = '"+info.getDazt()+"'";
	        }
		    sql2 = sql2 + " order by t.cjsj desc ) v ) where 1=1 ";
		    if (StringUtils.isNotEmpty(info.getXh())) {
		      sql2 = sql2 + " AND xh =  '" + info.getXh() + "'";
		      args.add(info.getXh());
		    }	    
		    sql+=" order by cjsj desc ";
		    List<DriverView> list=oraclePageDaoBase.query(sql2, new RowMapper<DriverView>() {
				private EntityTools<DriverView> et = new EntityTools<DriverView>();
				@Override
				public DriverView mapRow(ResultSet arg0, int arg1) throws SQLException {
					DriverView driver = new DriverView();
					et.setColumnsValueByResultSet(arg0, driver);	
					return driver;
				}
		    	   
			});
		    pages.setPage(list.get(0).getRowNumber());	    
		return oraclePageDaoBase.queryForGcPage(sql.toString(), pages, new RowMapper<DriverView>() {
			private EntityTools<DriverView> et = new EntityTools<DriverView>();
			@Override
			public DriverView mapRow(ResultSet arg0, int arg1)
					throws SQLException {
				DriverView veh = new DriverView();
				et.setColumnsValueByResultSet(arg0, veh);
				return veh;
			}
		}, new Object[]{});
	}*/

	@Override
	public List<DriverView> findDriverYxcjByxh(DriverView info) {
		String sql ="select * from DRIVER_PIC r where r.xh='"+ info.getXh()+ "'";
		List<DriverView> listVehicle= oraclePageDaoBase.query(sql, new RowMapper<DriverView>(){
			private EntityTools<DriverView> et = new EntityTools<DriverView>();
			@Override
			public DriverView mapRow(ResultSet arg0, int arg1) throws SQLException {
				DriverView veh = new DriverView();
				et.setColumnsValueByResultSet(arg0, veh);
				return veh;
			}});
		 Document doc=null;
		try {
			doc = DocumentHelper.parseText(listVehicle.get(0).getTpurl());
		} catch (DocumentException e1) {
			e1.printStackTrace();
		}
		 Element root = doc.getRootElement();
		 List nodes = root.elements();
		 List<DriverView> list = new ArrayList<DriverView>();
		 for (Iterator<?> it = nodes.iterator(); it.hasNext();) {
			 DriverView obj =new DriverView();
		 Element e = (Element) it.next();
		 obj.setId(e.attributeValue("id"));
		 obj.setSingleIpaddress(e.getStringValue());
		 try {
			obj.setSingleIpaddressEncrypt(toHexString(encrypt(e.getStringValue(), "ahhwxxjs")).toUpperCase());
		} catch (Exception e1) {
			e1.printStackTrace();
		}
		 list.add(obj);
		 }
	return list;
	}

	/*@Override
	public GcPage<DriverView> findDriverYxcjByxhUpAndDown(GcPage<DriverView> pages, DriverView info, String startTime,
			String endTime) {
		String sql="select t.*,decode(t.xb,'1','男','0','女','男') xbmc from DRIVER_RECORD t  where 1=1 ";
		List<Object> args = new ArrayList<Object>();
			if (StringUtils.isNotEmpty(info.getXh())) {
			    sql = sql + " and t.hphm = '" + info.getXh() + "'";
			}

		    if (StringUtils.isNotEmpty(startTime)) {
		      sql = sql + " AND t.cjsj >= to_date('" + startTime + "','yyyy-MM-dd hh24:mi:ss')";
		    }

		    if (StringUtils.isNotEmpty(endTime)) {
		      sql = sql + " AND t.cjsj <= to_date('" + endTime + "','yyyy-MM-dd hh24:mi:ss')";
		    }
		    if(StringUtils.isNotEmpty(info.getDazt()) && !info.getDazt().equals("4")){ //全部
	            sql =sql +" AND t.dazt ='"+info.getDazt()+"'";
	        }	    	    
		    sql +=" order by t.cjsj desc ";
		return oraclePageDaoBase.queryForGcPage(sql.toString(), pages, new RowMapper<DriverView>() {
			private EntityTools<DriverView> et = new EntityTools<DriverView>();
			@Override
			public DriverView mapRow(ResultSet arg0, int arg1)
					throws SQLException {
				DriverView veh = new DriverView();
				et.setColumnsValueByResultSet(arg0, veh);
				return veh;
			}
		}, new Object[]{});
	}*/

	@Override
	public Page<DriverView> finddriverYxshxx(Page<DriverView> pages, DriverView info, String startTime, String endTime,
			Sys_User user) {
		StringBuffer sql =new StringBuffer(
				"select t.*,decode(t.xb,'1','男','女') xbmc,h.xm cjrxm from DRIVER_RECORD t\n" +
				"left join SYS_USER h on t.cjr=h.yhdh where t.dazt = '1' ");
		 List<Object> args = new ArrayList<Object>();
		 
		 if(StringUtils.isNotEmpty(startTime)) {
				sql.append(" and t.cjsj >= to_date(?,'yyyy-MM-dd hh24:mi:ss') ");
				args.add(startTime);
			}
			if(StringUtils.isNotEmpty(endTime)) {
				sql.append(" AND t.cjsj <= to_date(?,'yyyy-mm-dd hh24:mi:ss') ");
				args.add(endTime);
			}
		    if(StringUtils.isNotEmpty(info.getDazt())){
		        sql.append(" AND t.dazt = ? ");
		        args.add(info.getDazt());
		    }
		    if(StringUtils.isNotEmpty(info.getSfzmhm())){
		        sql.append(" AND t.sfzmhm = ? ");
		        args.add(info.getSfzmhm());
		    }
		    sql.append(" order by t.cjsj desc ");
		return oraclePageDaoBase.queryForPage(sql.toString(), pages,new RowMapper<DriverView>() {
			private EntityTools<DriverView> et = new EntityTools<DriverView>();
			@Override
			public DriverView mapRow(ResultSet arg0, int arg1) throws SQLException {
				DriverView driver = new DriverView();
				et.setColumnsValueByResultSet(arg0, driver);
				return driver;
			}
		}, args.toArray());
	}

	/*@Override
	public List<DriverView> queryDriverList(DriverView info, String startTime, String endTime, PageUtil page) {
		    long currentPage=page.getCurrentPage();//当前页数
	        long pageSize=page.getPageSize();//每页大小
	        long max=(currentPage+1)*pageSize;
	        long min=(currentPage-1)*pageSize;
	        StringBuilder sql=new StringBuilder("select * from (");
	        sql.append(" select ROWNUM rn,xh FROM ( ");
	        sql.append(" select xh FROM DRIVER_RECORD t where 1=1 ");
	        if (StringUtils.isNotEmpty(startTime)) {
	            sql .append(" AND t.cjsj >= to_date('"+ startTime+"','yyyy-MM-dd hh24:mi:ss')");
	        }

	        if (StringUtils.isNotEmpty(endTime)) {
	           sql .append(" AND t.cjsj <= to_date('" + endTime + "','yyyy-MM-dd hh24:mi:ss')");
	        }
	       
	        String sfzmhm=info.getSfzmhm();
	        if (StringUtils.isNotEmpty(sfzmhm)) {
	           sql .append(sql + " AND t.sfzmhm='"+ sfzmhm+ "'");
	        }
	        sql.append(" ORDER BY T.CJSJ DESC ");
	        sql.append(" ) where rownum<'"+max+"' ");
	        sql.append(") where rn>'"+min+"' ");
	        List<DriverView> drivers= oraclePageDaoBase.query(sql.toString(), new BeanPropertyRowMapper<DriverView>(DriverView.class));
	        return drivers;
	}*/

	/*@Override
	public DriverView findDriverYxshFirstIn(DriverView info, String startTime, String endTime) {			
		 StringBuffer sql=new StringBuffer("select t.*,decode(t.xb,'1','男','女') xbmc,r.tpurl from DRIVER_RECORD t,DRIVER_PIC r where t.xh=r.xh and t.dazt = '1' ");
		    if (StringUtils.isNotEmpty(startTime)) {
		      sql.append(" AND t.cjsj >= to_date('" + startTime + "','yyyy-MM-dd hh24:mi:ss')");
		    }
		    
		    if (StringUtils.isNotEmpty(endTime)) {
		    	sql.append(" AND t.cjsj <= to_date('" + endTime + "','yyyy-MM-dd hh24:mi:ss')");
		    }
		 
		    String xh=info.getXh();
		    if (StringUtils.isNotEmpty(xh)) {
		    	sql.append(" AND t.xh =  '" + xh+ "'");
		    }	

		    //queryForObject在查询不到数据的时候会报空指针异常
		    List<DriverView> drivers=oraclePageDaoBase.query(sql.toString(),new BeanPropertyRowMapper<DriverView>(DriverView.class));
			if(drivers.size()>0){
				 info=drivers.get(0);
			}else{
				info=new DriverView();
			}
			 return info;
		}*/

	@Transactional(readOnly=false,rollbackFor=Exception.class)
	public boolean updateDriverYxshzt(DriverView info) {
		String sql="update DRIVER_RECORD set dazt=? where xh=? ";
		String sqlInsert = "insert into DRIVER_AUDIT\n" +
						   "select t.xh,t.dabh,t.sfzmhm,t.xm,t.xb,t.fzjg,t.cjsj,t.gxsj,t.cjr\n" + 
						   " from DRIVER_RECORD t where t.xh=?";

		List<Object> args = new ArrayList<Object>(); 
		if (StringUtils.isNotEmpty(info.getDazt())&&StringUtils.isNotEmpty(info.getXh())) {
			args.add(info.getDazt());
			args.add(info.getXh());
		 }else{
			 return false;
		 }
		//审核通过与否都要更新VEHICLE_RECORD表状态，然后根据审核状态确定是否插入VEHICLE_AUDIT(审核通过表)
		 int UpdateNum= oraclePageDaoBase.update(sql, args.toArray());
		//状态2为审核通过，则插入，否则不操作
		if(info.getDazt().equals("2")){
		 int insertNum=oraclePageDaoBase.update(sqlInsert, new Object[]{info.getXh()});
		 return UpdateNum>0 && insertNum>0 ? true : false;
		}
		return UpdateNum>0 ? true : false;
	}


	@Override
	public List<Vehicle> queryVehcileRecodeList(Vehicle info, Sys_Role sysRole) {
		// TODO Auto-generated method stub
		//oraclePageDaoBase.setSourceByRole(sysRole);
		/*StringBuffer sql=new StringBuffer(
			"select t.lsh,t.xh,t.ywlx,t.ywyy,r.ywmc,t.syr,t.hpzl,t.hphm,t.clpp1,t.xzqh,t.glbm,t.clsbdh,d.dmsm1 hpzlmc,'皖'||t.hphm hphmmc\n" +
			" from VEHICLE_RECORD t,VEH_OPERTYPE r,(select r.dmz,r.dmsm1 from FRM_CODE r where xtlb='00' and dmlb='1007') d\n" +  //号牌种类
			" where t.hpzl=d.dmz  and t.ywlx=r.ywlx and t.ywyy=r.ywyy and t.ywlx not in ('P','R') ");*/
		StringBuffer sql=new StringBuffer(
				"select t.lsh,t.xh,t.ywlx,t.ywyy,t.syr,t.hpzl,t.hphm,t.clpp1,t.xzqh,t.glbm,t.clsbdh,d.dmsm1 hpzlmc,'皖'||t.hphm hphmmc\n" +
				" from VEHICLE_RECORD t,(select r.dmz,r.dmsm1 from FRM_CODE r where xtlb='00' and dmlb='1007') d\n" +  //号牌种类
				" where t.hpzl=d.dmz ");
		  List<Object> args = new ArrayList<Object>();
		   if(StringUtils.isNotEmpty(info.getLsh())) {
				sql.append(" AND t.lsh = ? ");
				args.add(info.getLsh());
			}
		   if(StringUtils.isNotEmpty(info.getHphm())) {
				sql.append(" AND t.hphm = ? ");
				args.add(info.getHphm());
			}
		   if(StringUtils.isNotEmpty(info.getHpzl())) {
				sql.append(" and t.hpzl = ?");
				args.add(info.getHpzl());
			}
		   List<Vehicle> list;
		    if(sysRole.getRid().equals("43")){
		    	list = oraclePageDaoBase1.getRemoteJdbcTemplate().query(sql.toString(),args.toArray(), new BeanPropertyRowMapper<Vehicle>(Vehicle.class));
			}else{
				list=oraclePageDaoBase.query(sql.toString(),args.toArray(), new BeanPropertyRowMapper<Vehicle>(Vehicle.class));	
			}	   
		    StringBuffer buf=new StringBuffer();
	    	char[] ch;
			for(int i=0,size=list.size();i<size;i++){
		    	if(list.get(i).getYwlx()!=null && list.get(i).getYwlx().length()>=1){
		    		 List<Vehicle> operList=queryOpertype(list.get(i).getYwlx());
		    		 ch=list.get(i).getYwyy().toCharArray();
		    		 for(int j = 0;j<ch.length;j++){
		    			 for(Vehicle v : operList){
		    				 if(v.getYwyy().equals(String.valueOf(ch[j]))){
		    					 if(j==0){
		    						 buf.append(v.getYwmc());
		    					 }else{
		    						 buf.append("|"+v.getYwmc());	 
		    					 }
		    				 }
		    			 }
		    			}
		    		 list.get(i).setYwmc(buf.toString());
		    	}
			}	
		return  list;
	}


	@Override
	public Vehicle queryVehcileNotFlowObj(Vehicle info) {
		List<Object> args = new ArrayList<Object>();
		StringBuffer sql=new StringBuffer("select t.*,'皖'||t.hphm hphmmc from VEHICLE t where 1=1 ");
		if(StringUtils.isNotEmpty(info.getHphm())) {
			sql.append(" AND t.hphm = ? ");
			args.add(info.getHphm());
		}
	   if(StringUtils.isNotEmpty(info.getHpzl())) {
			sql.append(" and t.hpzl = ?");
			args.add(info.getHpzl());
		}
	    List<Vehicle> list=oraclePageDaoBase.query(sql.toString(),args.toArray(), new BeanPropertyRowMapper<Vehicle>(Vehicle.class));
		return list.size()>0 ? list.get(0) : null;
	}


	@Override
	public List<Vehicle> queryYwlxList(Vehicle info) {
		String sql = "select distinct t.ywlxmc, t.ywlx from veh_opertype t where t.ywlxmc is not null order by t.ywlx";
		List<Vehicle> list = oraclePageDaoBase.query(sql.toString(),new Object[]{}, new BeanPropertyRowMapper<Vehicle>(Vehicle.class));
		return list;
	}


	@Override
	public List<Vehicle> queryYwyyList(Vehicle info) {
		String sql = "select distinct t.ywmc,t.ywyy from veh_opertype t where t.ywlxmc is not null and t.ywlx=?";	
		List<Vehicle> list = oraclePageDaoBase.query(sql.toString(),new Object[]{info.getYwlx()}, new BeanPropertyRowMapper<Vehicle>(Vehicle.class));
		 return list;
	}


	@Override
	public boolean validateSbxh(String sbxh) {
		String sql ="select * from sbxx_record where sbxh=?";
		List<String> list = oraclePageDaoBase.query(sql, new Object[]{sbxh},new BeanPropertyRowMapper<String>(String.class));
		return list.size()>0 ? true : false;
	}

}